﻿using SketchUpAPI.NET.Enums;
using SketchUpAPI.NET.SketchUp.Exception;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace SketchUpAPI.NET.Objects
{
    [StructLayout(LayoutKind.Sequential, Pack = 8)]
    public struct BoundingBox3D
    {
        #region API 函数
        /// <summary>
        /// 获取边界的中心点
        /// </summary>
        /// <param name="box"></param>
        /// <param name="midPoint"></param>
        /// <returns></returns>
        [DllImport(ObjectBase.LIB)]
        static extern SUResult SUBoundingBox3DGetMidPoint(BoundingBox3D box, ref Point3D midPoint);
        #endregion

        public Point3D Min { get; set; }
        public Point3D Max { get; set; }

        /// <summary>
        /// 中心点
        /// </summary>
        public Point3D Mid
        {
            get
            {
                Point3D mid = new Point3D();
                SketchUpExceptionHelper.ThrowSUResult(SUBoundingBox3DGetMidPoint(this, ref mid));
                return mid;
            }
        }

        public BoundingBox3D(Point3D min, Point3D max)
        {
            Min = min;
            Max = max;
        }
    }
}
